<template>
  <Dialog
    :visible="addVisible"
    title="审核"
    :top="'25vh'"
    :width="480"
    @close="addVisible = false"
  >
    <div style="padding: 5px" v-if="addVisible">
      <el-form :model="formData" label-width="90px"  :labelPosition="'left'">
        <el-form-item label="审核结果：">
          <el-radio-group v-model="formData.orderStatus">
            <el-radio
              :label="item.value"
              v-for="(item, index) in PurchaseOrderStatusEnums"
            >
              {{ item.text }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注：">
          <el-input v-model="formData.refuseReason" style="border: 1px solid #f5f7fa;" type="textarea" />
        </el-form-item>
      </el-form>
    </div>
    <template #footer>
      <el-button @click="handleSubmit" type="primary">确 定</el-button>
      <el-button @click="addVisible = false">取 消</el-button>
    </template>
  </Dialog>
</template>

<script setup lang="ts">
import { auditReq } from '@/api/req';
const addVisible = ref(false);
import stores from '@/store';

// const PurchaseOrderStatusEnum = ref<any>(
//   stores.useBaseDataStore().getEnumSelect('purchaseOrderStatusEnum')
// );
// //console.log(PurchaseOrderStatusEnum,PurchaseOrderStatusEnum);

const PurchaseOrderStatusEnums = ref<any>(
 [
   {
    text:'同意',value:'2'
   },
   {
    text:'驳回',value:'3'
   }
 ]
);



const formData = ref<any>({
  orderId: '',
  orderStatus: PurchaseOrderStatusEnums.value[0].value,
  refuseReason: '',
});
defineExpose<{
  open: (menu: number) => void;
}>({
  open: (menu: number) => {
    formData.value = {
    orderId: '',
    orderStatus: PurchaseOrderStatusEnums.value[0].value,
    refuseReason: '',
  }
    formData.value.orderId = menu;
    addVisible.value = true;
  },
});

const handleSubmit = async () => {
  let res = await auditReq(formData.value);
  if (res.code == '200') {
    ElMessage({
      type: 'success',
      message: res.msg,
      duration: 2000,

    });
    closeDrawer();
  } else {
  }
};
const emit = defineEmits(['closeDrawer']);
const closeDrawer = () => {
  addVisible.value = false;
  emit('closeDrawer');
};
</script>
<style lang="scss" scoped></style>
